package com.signway.javaui.slice.component;

import com.signway.javaui.ResourceTable;
import com.signway.javaui.base.BaseAbilitySlice;
import com.signway.javaui.slice.component.listcontainer.domain.Item;
import com.signway.javaui.slice.component.listcontainer.provider.ItemProvider;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ListContainer;

import java.util.ArrayList;

public class ListContainerComponent extends BaseAbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_component_list_container);

        initView();
    }

    private void initView() {
        ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_list_container);
        ItemProvider itemProvider = new ItemProvider(this, getData());
        listContainer.setItemProvider(itemProvider);
    }

    ArrayList<Item> getData() {
        ArrayList<Item> items = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            Item item = new Item(ResourceTable.Media_icon, "Title", "Content" + i, "01:57");
            items.add(item);
        }
        return items;
    }
}
